<template>
	<view class="">
		<view class="tab_list">
			<view class="tabli" :class="type == 0 ? 'tabliactive' : ''" @click="changeFirTab(0)">全部</view>
			<view class="tabli" :class="type == 1 ? 'tabliactive' : ''" @click="changeFirTab(1)">我负责的</view>
			<view class="tabli" :class="type == 2 ? 'tabliactive' : ''" @click="changeFirTab(2)">下属负责的</view>
		</view>
		
		<!-- 筛选 -->
		<view class="searchbox">
			<view class="searchtext" @click="toQuery">筛选<view class="iconfont icon-shaixuan"></view></view>
		</view>
		
		<scroll-view scroll-y class="scrollbox" @scrolltolower="loodMore">
			<view class="payList">
				<cost-item :list="list"></cost-item>
			</view>
		</scroll-view>
		<view style="height: 200rpx;"></view>
		<view class="bot_total" @click="lookTotal">总金额合计> </view>
		<uni-popup ref="popup" type="bottom" background-color="#fff" @touchmove.stop.prevent>
			<view class="botwarp">
				<view class="wa_li">
					<view class="wa_label">总金额</view>
					<view class="wa_money"> <text>{{moneyInfo.allmoney?moneyInfo.allmoney:'0'}}</text>元 </view>
				</view>
				<view class="wa_li">
					<view class="wa_label">费用待审核总金额</view>
					<view class="wa_money"> <text>{{moneyInfo.inmoney?moneyInfo.inmoney:'0'}}</text>元 </view>
				</view>
				<view class="wa_li">
					<view class="wa_label">费用审核通过总金额</view>
					<view class="wa_money"> <text>{{moneyInfo.remoney?moneyInfo.remoney:'0'}}</text>元 </view>
				</view>
				<view class="wa_li">
					<view class="wa_label">费用审核未通过金额</view>
					<view class="wa_money"> <text>{{moneyInfo.nomoney?moneyInfo.nomoney:'0'}}</text>元 </view>
				</view>
				<view class="wa_btn" @click="removeTotal">取消</view>
			</view>
		</uni-popup>
		
		<view class="icon_creat" @click="addCost">
			<image :src="BASE_IMG_URL+'1.png'" mode="scaleToFill"></image>
		</view>
		
		<screen-pop ref="screenChild" @sureParams="surePa"></screen-pop>
	</view>
</template>

<script>
	import screenPop from './screen.vue'
	import { netCostList } from '@/api/kehu.js'
	import costItem from './item.vue'
	import { BASE_IMG_URL } from '@/util/api.js'
	
	export default{
		components:{
			screenPop,
			costItem
		},
		data() {
			return{
				BASE_IMG_URL:BASE_IMG_URL,
				type:0,
				page:1,
				totalPage:1,
				list:[],
				queryParams:{},
				moneyInfo:{}
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.init()
		},
		methods:{
			//查看总金额合计
			lookTotal() {
				this.$refs.popup.open()
			},
			removeTotal() {
				this.$refs.popup.close()
			},
			changeFirTab(type) {
				this.type = type
				this.init()
			},
			surePa(params){
				this.queryParams = params
				this.init()
			},
			toQuery() {
				this.$refs.screenChild.init()
			},
			loodMore() {
				if(this.page < this.totalPage){
					this.page ++
					this.getList()
				}
			},
			init() {
				this.page = 1
				this.list = []
				setTimeout(()=>{
					this.getList()
				},200)
			},
			getList() {
				let params = {
					type:this.type,
					page:this.page,
					...this.queryParams
				}
				netCostList(params).then(res=>{
					this.list = this.list.concat(res.data.data)
					this.totalPage = res.data.last_page
					this.moneyInfo = res.data.moneyinfo
				})
			},
			//新建费用
			addCost() {
				uni.navigateTo({
					url: '/pages/index/groupCompany/cost/addCost'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bot_total{
		position: fixed;
		left:0;
		bottom:0;
		width:750rpx;
		height:calc(80rpx + env(safe-area-inset-bottom) / 2);
		background:#fff;
		font-size:24rpx;
		color:#333;
		text-align: center;
		line-height: 80rpx;
		color:$uni-text-color;
		border-top:1rpx solid #f5f5f5;
		padding-bottom:calc(env(safe-area-inset-bottom) / 2);
	}
	.botwarp{
		background:#fff;
		padding:0 24rpx;
		.wa_li{
			padding:24rpx 35rpx;
			border-bottom:1rpx solid #f5f5f5;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.wa_label{
				font-size:24rpx;
				color:#333;
			}
			.wa_money{
				font-size:24rpx;
				color:#666;
				text{
					color:$uni-text-color;
				}
			}
		}
		.wa_btn{
			width:100%;
			height:100rpx;
			font-size:24rpx;
			color:$uni-text-color;
			text-align: center;
			line-height: 100rpx;
		}
	}
	.tab_list{
		width:750rpx;
		height:80rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		background:#fff;
		.tabli{
			font-size:24rpx;
			color:#333;
			line-height: 75rpx;
			text-align: center;
			border-bottom:4rpx solid #fff;
		}
		.tabliactive{
			border-bottom:4rpx solid $uni-text-color;
		}
	}
	.searchbox{
		display: flex;
		justify-content: flex-end;
		margin:24rpx;
		.searchtext{
			display: flex;
			justify-content: center;
			align-items: center;
			font-size:24rpx;
			color:$uni-text-color;
			padding:8rpx 28rpx;
			background:#fff;
			border-radius: 5rpx;
			box-shadow: 2rpx 2rpx 50rpx rgba(0,0,0,0.1);
			.icon-shaixuan{
				color:$uni-text-color;
			}
		}
	}
	.scrollbox{
		width:750rpx;
		height:calc(100vh - 180rpx);
	}
</style>